<template>
  <div>
    <div class="bidding-body">
      <div class="bidding-content">
        <Form :label-width="150">
          <div>
            <div class="bidding-item">
              <!-- <p>项目名称：</p> -->
              <FormItem label="项目名称：" prop="name">
                <Input class="bidding-item-input" v-model="infodetail.name" disabled />
              </FormItem>
            </div>
            <div class="bidding-item">
              <!-- <p>任务单编号：</p> -->
              <FormItem label="任务单编号：" prop="taskNumber">
                <Input class="bidding-item-input" v-model="infodetail.taskNumber" disabled />
              </FormItem>
            </div>
            <div class="bidding-item">
              <!-- <p>项目类别：</p> -->
              <FormItem label="项目类别：" prop="type">
                <Input class="bidding-item-input" v-model="infodetail.type" disabled />
              </FormItem>
            </div>
          </div>

          <div>
            <div class="bidding-item">
              <!-- <p>建设单位：</p> -->
              <FormItem label="建设单位：" prop="developmentOrganization">
                <Input
                  class="bidding-item-input"
                  v-model="infodetail.developmentOrganization"
                  disabled
                />
              </FormItem>
            </div>
            <div class="bidding-item">
              <!-- <p>联系人：</p> -->
              <FormItem label="联系人：" prop="contact">
                <Input class="bidding-item-input" v-model="infodetail.contact" disabled />
              </FormItem>
            </div>
            <div class="bidding-item">
              <!-- <p>联系方式：</p> -->
              <FormItem label="联系方式：" prop="contactPhone">
                <Input class="bidding-item-input" v-model="infodetail.contactPhone" disabled />
              </FormItem>
            </div>
          </div>

          <div>
            <div class="bidding-item">
              <!-- <p>项目编制人员：</p> -->
              <FormItem label="项目编制人员：" prop="editPersonId">
                <Select
                  v-model="infodetail.editPersonId"
                  clearable
                  style="width:200px"
                  :label-in-value="true"
                  disabled
                >
                  <Option
                    v-for="item in editPerList"
                    :value="item.id"
                    :key="item.id"
                  >{{ item.name }}</Option>
                </Select>
                <!-- <Input class="bidding-item-input" disabled/> -->
              </FormItem>
            </div>
            <div class="bidding-item">
              <!-- <p>项目负责人：</p> -->
              <FormItem label="项目负责人：" prop="principle">
                <Select
                  v-model="infodetail.principle"
                  clearable
                  style="width:200px"
                  :label-in-value="true"
                  disabled
                >
                  <Option v-for="item in allPeo" :value="item.id" :key="item.id">{{ item.name }}</Option>
                </Select>
                <!-- <Input class="bidding-item-input" v-model="infodetail.principle" disabled/> -->
              </FormItem>
            </div>
            <div class="bidding-item">
              <!-- <p>审核人员：</p> -->
              <FormItem label="审核人员：" prop="auditor">
                <Select
                  v-model="infodetail.auditor"
                  clearable
                  style="width:200px"
                  :label-in-value="true"
                  disabled
                >
                  <Option v-for="item in allPeo" :value="item.id" :key="item.id">{{ item.name }}</Option>
                </Select>
                <!-- <Input class="bidding-item-input" v-model="infodetail.auditor" disabled/> -->
              </FormItem>
            </div>
          </div>

          <div>
            <div class="bidding-item">
              <!-- <p>审核部门：</p> -->
              <FormItem label="审批部门：" prop="auditDepartmentName">
                <Input
                  class="bidding-item-input"
                  v-model="infodetail.auditDepartmentName"
                  disabled
                />
              </FormItem>
            </div>
            <div class="bidding-item">
              <!-- <p>审批文号：</p> -->
              <FormItem label="审批文号：" prop="auditNumber">
                <Input class="bidding-item-input" v-model="infodetail.auditNumber" disabled />
              </FormItem>
            </div>
            <div class="bidding-item">
              <!-- <p>审批时间</p> -->
              <FormItem label="审批时间：" prop="auditDate">
                <Input class="bidding-item-input" v-model="infodetail.auditDate" disabled />
              </FormItem>
            </div>
          </div>

          <div>
            <div class="bidding-item">
              <!-- <p>责任表审核人：</p> -->
              <FormItem label="负责表审核人：" prop="tableAuditor">
                <Select
                  v-model="infodetail.tableAuditor"
                  clearable
                  style="width:200px"
                  :label-in-value="true"
                  disabled
                >
                  <Option v-for="item in allPeo" :value="item.id" :key="item.id">{{ item.name }}</Option>
                </Select>
                <!-- <Input class="bidding-item-input" v-model="infodetail.tableAuditor" disabled/> -->
              </FormItem>
            </div>
            <div class="bidding-item">
              <!-- <p>工程等级：</p> -->
              <FormItem label="工程等级：" prop="projectLevel">
                <Input class="bidding-item-input" v-model="infodetail.projectLevel" disabled />
              </FormItem>
            </div>
            <div class="bidding-item">
              <!-- <p>行业类别：</p> -->
              <FormItem label="行业类别：" prop="industryType">
                <Input class="bidding-item-input" v-model="infodetail.industryTypeName" disabled />
              </FormItem>
            </div>
          </div>

          <div>
            <div class="bidding-item">
              <!-- <p>*所属地区：</p> -->
              <FormItem label="所属地区：" prop="province">
                <Input class="bidding-item-input" v-model="infodetail.province" disabled />
                <Input class="bidding-item-input" v-model="infodetail.city" disabled />
                <Input class="bidding-item-input" v-model="infodetail.area" disabled />
              </FormItem>
            </div>
          </div>

          <div>
            <div class="bidding-item">
              <!-- <p>生产规模：</p> -->
              <FormItem label="生产规模：" prop="productionScale">
                <Input class="bidding-item-input" v-model="infodetail.productionScale" disabled />
              </FormItem>
            </div>
            <div class="bidding-item">
              <!-- <p>实际完成工作日：</p> -->
              <FormItem label="实际完成工作日：" prop="realFinishDate">
                <Input class="bidding-item-input" v-model="infodetail.realFinishDate" disabled />
              </FormItem>
            </div>
          </div>

          <div>
            <div class="bidding-item">
              <!-- <p>环保投资：</p> -->
              <FormItem label="环保投资：" prop="envInvestment">
                <Input class="bidding-item-input" v-model="infodetail.envInvestment" disabled />
              </FormItem>
            </div>
            <div class="bidding-item">
              <!-- <p>总投资：</p> -->
              <FormItem label="总投资：" prop="totalInvestment">
                <Input class="bidding-item-input" v-model="infodetail.totalInvestment" disabled />
              </FormItem>
            </div>
          </div>

          <div>
            <div class="bidding-item">
              <!-- <p>备注：</p> -->
              <FormItem label="备注：" prop="remark">
                <Input
                  disabled
                  v-model.trim="infodetail.editRemark"
                  type="textarea"
                  style="width: 910px"
                />

                <!-- <Input type="areatext" v-model="infodetail.editRemark" disabled/> -->
              </FormItem>
            </div>
          </div>
        </Form>
      </div>
    </div>
  </div>
</template>
<script>
import axios from "axios";
export default {
  name: "authorizenews",
  data() {
    return {
      editPersonId: {},
      editPerson: "",
      infodetail: {
        auditDepartment: "", //审核部门ID

        principle: "", //项目负责人
        auditDepartmentName: "", //审核部门名称
        city: "", //市
        type: "", //项目类别
        industryType: "", //行业类别
        province: "", //省
        developmentOrganization: "", //建设单位
        contact: "", //联系人
        tableAuditor: "", //责任表审核人
        auditDate: "", //审批日期
        area: "", //区
        auditor: "", //审核人员
        taxNumber: "", //任务单编号
        name: "", //项目名称
        editRemark: "", //备注
        taskNumber: "", //任务单编号
        contactPhone: "", //联系方式
        auditNumber: "", //审批文号
        projectLevel: "", //工程等级
        productionScale: "", //生产规模
        realFinishDate: "", //实际完成工作日
        envInvestment: "", //环保投资
        totalInvestment: "" //总投资
      },
      proType: [], //项目类别名单
      //editPeo: [], //项目编制人员名单
      dptList: [], //所有部门列表
      carerType: [], //所有行业类别
      allPeo: [], //所有人的名单
      allPeoPages: null,
      editPerList: [], //编制权限人名单
      dataTree: []
    };
  },
  created: function() {
    // console.log(this.callbackdata);
    axios({
      method: "get",
      url: this.IP.IP + "/edit/getEdit?projectId=" + this.callbackdata
    }).then(result => {
      // console.log(this.row);
      this.infodetail = result.data.data;
      this.infodetail.editPersonId = this.infodetail.editPersonId + "";
      this.infodetail.principle = this.infodetail.principle + "";
      this.infodetail.auditor = this.infodetail.auditor + "";
      //this.infodetail.auditDepartmentName=this.infodetail.auditDepartmentName+"";
      this.infodetail.tableAuditor = this.infodetail.tableAuditor + "";
      // console.log(this.infodetail);
    });
  },
  props: ["callbackdata"],
  beforeMount() {
    this.getproType(); //项目类别
    this.getdepartments(); //得到部门的name和ID

    this.getCarerType(); //行业类别
    this.getEditpersonList(); //编制人员
    this.getAllPeo(); //得到所有人
    //this.getCityData();
  },
  methods: {
    getproType() {
      axios({
        method: "get",
        url: this.IP.IP + "/getProjectTypes?pageNumber=" + 1
      }).then(result => {
        var total = result.data.data.total;
        var list = result.data.data.list;
        for (var i = 0; i < total; i++) {
          this.proType.push({
            id: list[i].id + "",
            name: list[i].name + ""
          });
        }
        // console.info("项目类别");
        // console.log(this.proType);
      });
    },
    insertPeo() {
      // console.info("insetr");
      // console.log(this.allPeoPages);
      var i = 1;
      for (i = 1; i <= this.allPeoPages; i++) {
        axios({
          method: "get",
          url: this.IP.IP + "/personInfo/show?pageNum=" + i + "&pageSize=" + 10
        }).then(result => {
          var total = result.data.data.list.length;
          var list = result.data.data.list;
          // console.info("lentgh");
          // console.info(total);
          // console.log(list);
          for (var j = 0; j < total; j++) {
            this.allPeo.push({
              id: list[j].id + "",
              name: list[j].name + ""
            });
            // console.info(i);
            // console.log(this.allPeo);
          }
        });
      }
      // console.info("所有人名单");
      // console.log(this.allPeo);
    },
    getAllPeo() {
      axios({
        method: "get",
        url: this.IP.IP + "/personInfo/show?pageNum=" + 1 + "&pageSize=" + 10
      }).then(result => {
        this.allPeoPages = result.data.data.pages;
        // console.info("pages111");
        // console.log(this.allPeoPages);
        this.insertPeo();
      });
      //this.insertPeo();
    },
    getEditpersonList() {
      axios({
        method: "get",
        url: this.IP.IP + "/personInfo/getEditPerson"
      }).then(result => {
        var total = result.data.data.length;
        var list = result.data.data;
        for (var i = 0; i < total; i++) {
          this.editPerList.push({
            id: list[i].personId + "",
            name: list[i].personName + ""
          });
        }
        // console.info("编制人名单");
        // console.log(this.editPerList);
      });
    },
    getCarerType() {
      axios({
        method: "get",
        url: this.IP.IP + "/getIndustryTypes?pageNumber=" + 1
      }).then(result => {
        var total = result.data.data.total;
        var list = result.data.data.list;
        for (var i = 0; i < total; i++) {
          this.carerType.push({
            id: list[i].id + "",
            name: list[i].name + ""
          });
        }
        // console.info("行业类别名单");
        // console.log(this.carerType);
      });
    },
    getdepartments() {
      axios({
        method: "get",
        url: this.IP.IP + "/getDepartments"
      }).then(result => {
        // console.info("部门信息");
        // console.log(result);
        var data = result.data.data;
        this.dataTree = [];
        var i = 0;
        for (i = 0; i < data.length; i++) {
          this.setNode(data[i]);
        }
        this.dataTree = data;
        this.dataTree.unshift({ id: 0, name: "全部", children: [] });
        // console.info("部门树");
        // console.log(this.dataTree);
        // console.info("部门列表");
        // console.log(this.dptList);
        //console.info('')
        //console.log(this.valueId);
      });
    },
    setNode(node) {
      if (node != null) {
        node.name = node.nodeDepartmentIndex.name;
        node.id = node.nodeDepartmentIndex.id;
        node.children = node.childrenDepartmentIndexes;
        this.dptList.push({
          id: node.id + "",
          name: node.name
        });
        var i = 0;
        for (i = 0; i < node.childrenDepartmentIndexes.length; i++) {
          this.setNode(node.childrenDepartmentIndexes[i]);
        }
      }
    }
  }
};
</script>
<style>
.auth-content {
  padding: 10px 5px;
  border-bottom: 1px dashed #cdcdcd;
}
</style>